package net.wantongtech.xa.uploadbasicinfo;

import lombok.extern.slf4j.Slf4j;
import net.wantongtech.xa.uploadbasicinfo.config.TollBasicInfoConfig;
import net.wantongtech.xa.uploadbasicinfo.service.*;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.transaction.annotation.EnableTransactionManagement;

@Slf4j
@SpringBootApplication
@EnableTransactionManagement(proxyTargetClass = true)
public class UploadBasicInfoApplication {


    @Bean
    public TollBasicInfoConfig tollBasicInfoConfig() {
        return new TollBasicInfoConfig();
    }

    public static void main(String[] args) {
        if (args == null || args.length == 0) {
            log.info("请输入要运行的服务");
            return;
        }
        ConfigurableApplicationContext context = new SpringApplicationBuilder()
                .web(WebApplicationType.NONE)
                .sources(UploadBasicInfoApplication.class)
                .run(args);
        String type = args[0];
        switch (type) {
            case "1":
                CorrectMergeTransVehPlateService correctMergeTransVehPlateService =
                        context.getBean(CorrectMergeTransVehPlateService.class);
                correctMergeTransVehPlateService.correct();
                break;
            case "2":
                MarkMergeTransStateService markMergeTransStateService =
                        context.getBean(MarkMergeTransStateService.class);
                markMergeTransStateService.mark();
                break;
            case "3":
                DownloadClearPackageService service = context.getBean(DownloadClearPackageService.class);
                service.download();
                break;
            case "4":
                FillHistoryDisputedDataService fillHistoryDisputedDataService =
                        context.getBean(FillHistoryDisputedDataService.class);
                fillHistoryDisputedDataService.fill();
                break;
            case "5":
                CheckMissingDisputedTransService checkMissingDisputedTransService =
                        context.getBean(CheckMissingDisputedTransService.class);
                checkMissingDisputedTransService.checkV2();
                break;
            case "6":
                DownloadMissingRefundDataService downloadMissingRefundDataService = context.getBean(DownloadMissingRefundDataService.class);
                downloadMissingRefundDataService.download();
                break;
            case "7":
                DealWithRefundDataService dealWithRefundDataService = context.getBean(DealWithRefundDataService.class);
                dealWithRefundDataService.dealWith();
                break;
            case "8":
                PostPoneAnnualCardTimeService postPoneAnnualCardTimeService = context.getBean(PostPoneAnnualCardTimeService.class);
                postPoneAnnualCardTimeService.postPone();
                break;
            case "9":
                ErrorUserTypeService errorUserTypeService = context.getBean(ErrorUserTypeService.class);
                errorUserTypeService.process();
                break;
            case "10":
                ReCreateFullAnnualListService reCreateFullAnnualListService = context.getBean(ReCreateFullAnnualListService.class);
                reCreateFullAnnualListService.reCreate();
                break;
            default:
                log.info("指定类型不存在");
        }
    }

}
